import constant from './constant';
import Mock from 'mockjs';
import common from './common'
import tools from '../dll/libs/common/tools.js'

const shIndexData = [322679, 322671, 323001, 323325, 323378, 323380, 323267, 323153, 323220, 323246,
  323315, 323396, 323430, 323361, 323159, 322972, 322891, 322987, 323069, 323029,
  322985, 322994, 322976, 322952, 323079, 323241, 323300, 323340, 323402, 323461,
  323531, 323493, 323248, 323050, 322912, 322937, 322910, 322963, 322904, 322886,
  322954, 322899, 323151, 323295, 323382, 323437, 323488, 323426, 323390, 323311,
  323305, 323421, 323432, 323466, 323491, 323575, 323530, 323509, 323351, 323229,
  323152, 323314, 323227, 323242, 323264, 323250, 323333, 323311, 323342, 323314,
  323326, 323255, 323293, 323255, 323156, 323159, 323057, 323197, 323348, 323468,
  323564, 323718, 323916, 323894, 323852, 323753, 323782, 323666, 323711, 323703,
  323565, 323517, 323474, 323596, 323588, 323540, 323568, 323617, 323627, 323690,
  323832, 323889, 323928, 323969, 323963, 323896, 323906, 323889, 323910, 323900,
  323905, 323957, 323930, 323885, 323758, 323662, 323651, 323595, 323607, 323580,
  323658, 323726, 323681, 323649, 323681, 323669, 323679, 323697, 323735, 323738,
  323688, 323753, 323726, 323772, 323780, 323793, 323780, 323684, 323653, 323614,
  323599, 323569, 323564, 323629, 323630, 323711, 323708, 323774, 323812, 323886,
  323965, 323941, 324017, 324022, 324021, 324028, 323999, 323938, 323969, 323974,
  323977, 323976, 324083, 324267, 324491, 324524, 324495, 324515, 324426, 324429,
  324302, 324217, 324112, 324061, 323982, 323998, 323949, 323959, 323927, 324127,
  324175, 324268, 324262, 324264, 324247, 324272, 324281, 324342, 324431, 324513,
  324509, 324528, 324467, 324496, 324520, 324520, 324419, 324247, 324161, 324093,
  324031, 323891, 323848, 323852, 323810, 323778, 323734, 323790, 323809, 323936,
  323908, 323972, 324001, 324095, 324134, 324205, 324168, 324204, 324093, 324107,
  324023, 324008, 324035, 323975, 323954, 323871, 323823, 323903, 323981, 324029,
  324037, 324174, 324073, 324120, 324087, 324173, 324238, 324274, 324310, 324423,
  324486].map(item => item / 100)

const szIndexData = [1028868, 1028568, 1029402, 1030954, 1031813, 1031919, 1031672, 1031301, 1031212, 1031577,
  1032505, 1033364, 1033382, 1032991, 1032637, 1032273, 1032040, 1032494, 1032905, 1033098,
  1033102, 1033136, 1033450, 1033919, 1034301, 1034850, 1035439, 1035629, 1036031, 1036497,
  1036842, 1036625, 1036093, 1035311, 1034588, 1034461, 1034702, 1034655, 1034507, 1034435,
  1034546, 1034625, 1034955, 1035687, 1036510, 1036599, 1036753, 1036589, 1036575, 1036723,
  1036843, 1036945, 1037246, 1037360, 1037592, 1037671, 1037610, 1037160, 1036851, 1036472,
  1036032, 1035900, 1036001, 1036260, 1036304, 1036244, 1036272, 1036203, 1036196, 1036085,
  1035791, 1035625, 1035436, 1035422, 1035097, 1034911, 1034710, 1034878, 1035173, 1035505,
  1035853, 1036271, 1036802, 1036896, 1036722, 1036575, 1036758, 1036783, 1036878, 1036769,
  1036461, 1036142, 1036121, 1036169, 1036183, 1036144, 1036091, 1036001, 1036260, 1036600,
  1036883, 1037231, 1037343, 1037584, 1037524, 1037589, 1037526, 1037508, 1037539, 1037461,
  1037594, 1037648, 1037426, 1037098, 1036672, 1036394, 1036300, 1036176, 1036228, 1036208,
  1036426, 1037012, 1036983, 1036860, 1036764, 1036800, 1036693, 1036635, 1036814, 1036937,
  1036981, 1036968, 1037102, 1037143, 1037231, 1037142, 1037319, 1036817, 1036378, 1036360,
  1036358, 1036324, 1036469, 1036505, 1036712, 1037028, 1037348, 1037580, 1037863, 1038182,
  1038474, 1038591, 1038641, 1038657, 1038645, 1038528, 1038285, 1038224, 1037983, 1037826,
  1037588, 1037596, 1037684, 1038475, 1039009, 1039070, 1039072, 1038985, 1039097, 1039014,
  1038502, 1038051, 1037701, 1037181, 1037011, 1037009, 1037029, 1036758, 1036734, 1036951,
  1037310, 1037493, 1037577, 1037491, 1037390, 1037448, 1037550, 1037689, 1037861, 1037949,
  1038111, 1038240, 1038346, 1038536, 1038619, 1038585, 1038169, 1037826, 1037410, 1037113,
  1036979, 1036780, 1036411, 1036268, 1036103, 1036064, 1036022, 1036127, 1036190, 1036439,
  1036675, 1036700, 1036974, 1037269, 1037422, 1037482, 1037562, 1037379, 1037339, 1037460,
  1037291, 1037259, 1037149, 1036935, 1036595, 1036274, 1036220, 1036264, 1036260, 1036459,
  1036532, 1036560, 1036448, 1036322, 1036192, 1036284, 1036361, 1036378, 1036374, 1036374,
  1036698].map(item => item / 100)

const cybIndexData = [168426, 168362, 168562, 168706, 168834, 168875, 168877, 168801, 168789, 168973,
  169297, 169561, 169712, 169668, 169677, 169669, 169676, 169786, 169889, 169932,
  169864, 169819, 169978, 170172, 170293, 170387, 170496, 170566, 170621, 170704,
  170828, 170884, 170813, 170626, 170569, 170583, 170646, 170697, 170750, 170684,
  170652, 170628, 170760, 170882, 171059, 171068, 171083, 171098, 171085, 171108,
  171139, 171131, 171135, 171174, 171233, 171238, 171220, 171135, 171010, 170947,
  170879, 170842, 170852, 170862, 170917, 170935, 170945, 170897, 170888, 170826,
  170789, 170760, 170771, 170753, 170771, 170721, 170634, 170595, 170605, 170622,
  170708, 170726, 170762, 170742, 170700, 170613, 170649, 170649, 170674, 170729,
  170691, 170648, 170637, 170622, 170605, 170604, 170607, 170616, 170624, 170673,
  170720, 170776, 170778, 170802, 170772, 170823, 170809, 170815, 170845, 170842,
  170860, 170844, 170799, 170701, 170589, 170568, 170510, 170474, 170437, 170408,
  170364, 170420, 170417, 170433, 170416, 170421, 170387, 170397, 170387, 170430,
  170439, 170429, 170424, 170404, 170409, 170409, 170359, 170318, 170285, 170259,
  170221, 170230, 170212, 170214, 170214, 170271, 170301, 170342, 170303, 170313,
  170293, 170333, 170312, 170332, 170299, 170200, 170178, 170162, 170113, 170087,
  170071, 170043, 170043, 170111, 170154, 170140, 170116, 170070, 170086, 170074,
  170017, 169951, 169841, 169788, 169778, 169735, 169718, 169691, 169659, 169680,
  169731, 169728, 169741, 169728, 169712, 169686, 169680, 169702, 169708, 169709,
  169713, 169721, 169696, 169715, 169687, 169642, 169509, 169472, 169375, 169321,
  169298, 169239, 169244, 169248, 169200, 169138, 169138, 169109, 169122, 169174,
  169238, 169295, 169312, 169313, 169278, 169254, 169251, 169225, 169234, 169202,
  169170, 169167, 169131, 169059, 168977, 168951, 168916, 168892, 168865, 168872,
  168897, 168837, 168854, 168833, 168826, 168817, 168808, 168832, 168826, 168826,
  168861].map(item => item / 100)

const Random = Mock.Random;

Mock.setup({
  timeout: '200-1000'
})

const getDataLength = () => {
  let d = new Date();
  if (common.verifyTime(d)) {
    let tmpLen = ((d.getTime() - new Date(d.getFullYear(), d.getMonth(), d.getDate(), 9, 30).getTime()) / 1000 / 60).toFixed(0);
    let judge = `${common.fullZero(d.getHours())}:${common.fullZero(d.getMinutes())}` > '11:30'
    return judge ? tmpLen - 89 : tmpLen
  } else {
    let hs = `${common.fullZero(d.getHours())}:${common.fullZero(d.getMinutes())}`;
    return (hs > '11:30' && hs < '13:00') ? 120 : 241;
  }
}

// // 0.1获取大盘最新收盘指数
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_LAST_INDEX, (obj) => {
  let body = JSON.parse(obj.body) || '';

  switch (Number(body.type)) {
    case 0:
      return 3230.98;
    case 1:
      return 10295.57;
    case 2:
      return 3283;
  }
})

// 0.1获取大盘指数数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_INDEX, (obj) => {
  const body = JSON.parse(obj.body) || '';
  const length = getDataLength();

  switch (Number(body.type)) {
    case 0:
      return {
        index: shIndexData.slice(0, length),
        closing: 3230.98
      };
    case 1:
      return {
        index: shIndexData.slice(0, length),
        closing: 3230.98
      };
    case 2:
      return {
        index: szIndexData.slice(0, length),
        closing: 10295.57
      };
    case 3:
      return {
        index: cybIndexData.slice(0, length),
        closing: 3283
      };
  }
});

// // 1.1 ---获取当前时间涨跌分布
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_CHG_DIS, (params) => {
  switch (Number(JSON.parse(params.body).type)) {
    case 0:
      return [10, 20, 40, 70, 30, 44, 20];
    case 1:
      return [20, 30, 40, 80, 100, 24, 50];
    case 2:
      return [30, 10, 20, 100, 50, 64, 20];
    case 3:
      return [20, 33, 20, 66, 100, 54, 30]
  }
})

// // 1.2 ---获取今日观点数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_OPINION, () => {
  return {
    gainOpinion: 80,
    slipOpinion: 132
  }
})

// // 1.3 ---获取本人今日观点
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_MY_OPINION, (params) => {
  return '看涨'
})

// // 1.4 ---设置今日本人观点
Mock.mock(constant.baseURL + constant.InterfaceEnum.SET_MY_OPINION, (params) => {
  switch (params.body) {
    case 0:
      console.log('用户选择看涨');
      break;
    case 1:
      console.log('用户选择看跌');
      break;
    case 2:
      console.log('用户取消选择');
      break;
  }
})

// 1.5 ---获取资金动态数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_FUND_TRENDS, (date) => {
  return {
    market: { // 市场资金
      flowDays: 10, // 天数
      todayIn: 20, // 今日流入
      todayOut: 15, // 今日流出
      type: 20, // 0净流入，1净流出
      dataTime: '2017-07-03 11:00' // 数据日期yyyy-MM-dd HH:mm
    },
    shConnect: { // 沪股通资金
      flowDays: 10, // 净流入或者净流出天数
      flowType: 0, //  0流入，1流出
      today: 20, // 今日净流入或者净流出
      todayType: 0 // 0流入，1流出
    },
    szConnect: { // 深股通资金
      flowDays: 10, // 净流入或者净流出天数
      flowType: 0, // 0流入，1流出
      today: 10, // 今日净流入或者净流出
      todayType: 0 // 0 流入，1流出
    },
    largeOrder: { // 大单资金
      flowDays: 10, // 净流入或者净流出天数
      flowType: 0, // 流入，1流出
      today: 20, // 今日净流入或者净流出
      todayType: 0 // 0 流入，1流出
    },
    cb: 10, // 央行资金(今日净投放、净回笼)
    cbType: 0, // 0净投放，1净回笼
    shibor: 111, // shibor
    finance: -11, // 融资余额(比前一交易日增加或者减少，前端注意正负)
    lifted: 223, // 解禁市值
    lastWeek: { // 上周银证转帐
      in: 30,
      out: 23,
      date: '2017-07-03 11:00' // 截至日期；yyyy-MM-dd
    }
  }
})

 // 1.6 ---获取市场人气
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_M_POPULAR, (date) => {
  return {
    lastTreeMonth: {
      dateArray: ['03.01', '03.02', '03.03', '03.04', '03.05', '03.06, 03.07', '03.08', '03.09', '03.10', '03.11', '03.12'],
      accountOpen: [440, 380, 420, 500, 324, 236, 400, 295, 320, 400, 236, 349],
      trade: [80, 128, 133, 170, 154, 166, 170, 90, 100, 110, 146, 139],
      shIndex: [3000, 3100, 3150, 3230, 3250, 3110, 3150, 3230, 3250, 3110, 3230, 3250]
    },
    topSearch: {
      module: '',
      strName: '',
      strCode: ''
    }
  }
})

// 2.1 ---获取当日实时涨跌数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_TRENDS, (params) => {
  let length = 141;
  if (JSON.parse(params.body).startTime) {
    length = 1;
  }
  return {
    xTime: common.getTradeTimeArr(),
    gain: Array.from({length}, () => Math.floor((Math.random()) * 40)),
    slip: Array.from({length}, () => Math.floor((Math.random()) * 40))
  }
})

// 2.2 ---获取当日涨跌停股票板块分布数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_MO_TRENDS, (obj) => {
  return {
    distribution: {
      up: Array.from({length: 12}, () => {
        return {
          moduleName: Random.cword(4),
          nNum: Random.integer(5, 30),
          nSum: Random.integer(100, 200)
        }
      }),
      down: Array.from({length: 12}, () => {
        return {
          moduleName: Random.cword(4),
          nNum: Random.integer(5, 30),
          nSum: Random.integer(100, 200)
        }
      })
    }
  }
})

// 2.3 ---获取次日／五日表现
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_FUTURE_PF, (obj) => {
  console.log(obj)
  return {
    xTime: common.getTradeTimeArr(),
    average: Array.from({length: 241}, () => Math.floor((Math.random()) * 40))
  }
})

// 3.1 ---获取急涨急跌数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_RAPID_CHG, (params) => {
  let length1 = length;

  if (JSON.parse(params.body).startTime) {
    length1 = 1;
  }

  return {
    xTime: common.getTradeTimeArr(),
    netNumber: Array.from({length: length1}, () => Math.floor((Math.random() - 0.5) * 60)),
    minute: {
      gain: Array.from({length: length1}, () => Math.floor((Math.random()) * 40)),
      slip: Array.from({length: length1}, () => Math.floor((Math.random()) * 40))
    }
  }
})

// 3.2 ---获取当日涨跌停股票板块分布数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_RAPID_MO_CHG, (type) => {
  const length = getDataLength();
  return {
    distribution: {
      up: Array.from({length: 12}, () => {
        return {
          moduleName: Random.cword(4),
          nNum: Random.integer(5, 30),
          nSum: Random.integer(100, 200)
        }
      }),
      down: Array.from({length: 12}, () => {
        return {
          moduleName: Random.cword(4),
          nNum: Random.integer(5, 30),
          nSum: Random.integer(100, 200)
        }
      })
    }
  }
})

// 3.3 ---获取当前急涨急跌股票
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_RAPID_STOCK, (index) => {
  return Array.from({length: 10}, () => {
    return {
      strCode: Random.string('number', 6),
      strName: Random.cword(3, 4),
      nPrice: Random.float(5, 400, 2, 2),
      n1Rate: Random.float(0, 5, 2, 2),
      n2Rate: Random.float(0, 1, 2, 2)
    }
  })
})

// // 4.1 ---获取当前市场资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_M_FUND, (index) => {
  const length = getDataLength();
  return {
    xTime: common.getTradeTimeArr(),
    netNumber: Array.from({length}, () => Math.floor((Math.random() - 0.5) * 60)),
    minute: {
      in: Array.from({length}, () => Math.floor((Math.random()) * 40)),
      out: Array.from({length}, () => Math.floor((Math.random()) * 40))
    }
  }
})

// // 4.2 ---获取当前市场资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_M_MODULE, (index) => {
  return {
    distribution: {
      up: Array.from({length: 12}, () => {
        return {
          moduleName: Random.cword(4),
          nNum: Random.integer(5, 30),
          nSum: Random.integer(100, 200)
        }
      }),
      down: Array.from({length: 12}, () => {
        return {
          moduleName: Random.cword(4),
          nNum: Random.integer(5, 30),
          nSum: Random.integer(100, 200)
        }
      })
    },
    stocks: Array.from({length: 8}, () => {
      return {
        strName: '中国中车',
        strCode: 601688,
        nPrice: 23.56,
        nAmount: 0.73,
        nRate: +0.73,
        netFlowIn: 300
      }
    })
  }
})

// // 4.3 ---获取近三个月市场资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_L3M_MFUND, (index) => {
  console.log(index)
  let time = new Date();
  return {
    xTime: Array.from({length: 90}, () => {
      time.setDate(time.getDate() - 1)
      return tools.DateFormat(time, 'MM.dd');
    }),
    in: Array.from({length: 90}, () => Math.floor((Math.random()) * 40)),
    out: Array.from({length: 90}, () => Math.floor((Math.random() - 1) * 40)),
    indexData: Array.from({length: 241}, () => Random.integer(2900, 3190))
  }
})

// 5.1 ---获取当日沪深股通资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_CONN_FUND, (obj) => {
  const body = JSON.parse(obj.body) || '';
  const length = getDataLength();
  let stocks = Array.from({length: 10}, () => {
    return {
      strName: Random.cword(3, 4),
      strCode: Random.integer(610688, 620000),
      nPrice: Random.float(20, 30, 2, 2),
      nAmount: Random.float(0, 0, 2, 2),
      nRate: Random.float(-1, 1, 2, 2),
      netFlowIn: Random.integer(2000000, 300000000)
    }
  });
  let xTime = common.getTradeTimeArr().slice(0, length).map(v => v.replace(':', ''));
  let netNumber = Array.from({length}, () => Random.integer(-30, 30));
  let minute = {
    in: Array.from({length}, () => Random.integer(0, 30)),
    out: Array.from({length}, () => Random.integer(0, 30))
  };
  let shData = {
    sumIn: Random.integer(300000000, 500000000),
    sumOut: Random.integer(300000000, 500000000),
    stocks,
    xTime,
    netNumber,
    minute
  };
  let szData = {
    sumIn: Random.integer(300000000, 500000000),
    sumOut: Random.integer(300000000, 500000000),
    stocks,
    xTime,
    netNumber,
    minute
  };
  if (!body.type) return shData
  else return szData
})

// 5.2 --- 获取最近沪深股通资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_LST_CONN_FUND, (obj) => {
  let body = JSON.parse(obj.body) || ''
  let length;
  let date;
  switch (body.type) {
    case 0:
      length = 30;
      date = common.getDate('MM.dd', length)
      break;
    case 1:
      length = 91;
      date = common.getDate('yyyyMMdd', length)
      break;
    case 2:
      length = 365;
      date = common.getDate('yyyyMMdd', length)
      break;
  }
  const getIntoflow = (length) => {
    return Array.from({length}, () => Math.ceil(Math.random() * 30))
  }
  const getOutflow = (length) => {
    return Array.from({length}, () => Math.ceil(Math.random() * -28))
  }
  const getIndexData = (length) => {
    return Array.from({length}, () => (Random.integer(2900, 3300)))
  }
  if (!body.marketType || body.marketType) {
    return {
      date,
      indexData: getIndexData(length),
      in: getIntoflow(length),
      out: getOutflow(length)
    }
  }
})

// 7.1 获取当日大单资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_L_O_FUND, (index) => {
  console.log(1)
  const length = getDataLength();
  return {
    startTime: '',
    endTime: '',
    xTime: common.getTradeTimeArr(),
    netNumber: Array.from({length}, () => Math.floor((Math.random() - 0.5) * 60)),
    minute: {
      in: Array.from({length: 241}, () => Math.floor((Math.random()) * 40)),
      out: Array.from({length: 241}, () => Math.floor(Math.random() * 40))
    },
    stocks: Array.from({length: 8}, () => {
      return {
        strName: '中国中车',
        strCode: 601688,
        nPrice: 23.56,
        nAmount: 0.73,
        nRate: +0.73,
        netFlowIn: 300
      }
    })
  }
})

// // 7.2 获取最近大单资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_LST_L_O_FUND, (index) => {
  console.log(2)
  let time = new Date();
  return {
    xTime: Array.from({length: 90}, () => {
      time.setDate(time.getDate() - 1)
      return tools.DateFormat(time, 'MM.dd');
    }),
    shIndex: Array(241).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 1000) + 1200 }),
    in: Array.from({length: 90}, () => Math.floor((Math.random()) * 40)),
    out: Array.from({length: 90}, () => Math.floor((Math.random() - 1) * 40))
  }
})

// 8.1 获取央行资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_C_B_FUND, (index) => {
  console.log(1)
  return {
    cbOut: Mock.Random.float(0, 900, 0, 0),
    cbIn: Mock.Random.float(0, 900, 0, 0),
    ypdq: Mock.Random.float(0, 900, 0, 0),
    zhgdq: Mock.Random.float(0, 900, 0, 0),
    nhgfx: Mock.Random.float(0, 900, 0, 0),
    ypfx: Mock.Random.float(0, 900, 0, 0),
    zhgfx: Mock.Random.float(0, 900, 0, 0),
    nhgdq: Mock.Random.float(0, 900, 0, 0)
  }
})

// 8.2 获取最近央行资金数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_LST_C_B_FUND, (index) => {
  console.log(2)
  let time = new Date();
  return {
    xTime: Array.from({length: 90}, () => {
      time.setDate(time.getDate() - 1)
      return tools.DateFormat(time, 'MM.dd');
    }),
    shIndex: Array(241).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 1000) + 1200 }),
    in: Array.from({length: 90}, () => Math.floor((Math.random()) * 40)),
    out: Array.from({length: 90}, () => Math.floor((Math.random() - 1) * 40))
  }
})

// 9.1 获取近三月Shibor数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_L3M_SHIBOR, () => {
  console.log(1)
  return {
    shiborData: {
      xTime: common.getTradeTimeArr(),
      shIndex: Array(241).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 1000) + 1200 }),
      shibor: Array(241).join(' ').split('').map((item, index) => { return Mock.Random.float(-0, 6, -2, 2) })
    }
  }
})

// 9.2 今日shibor列表
const getShiborData = () => {
  let resultArr = [];
  Mock.Random.extend({
    dateLine: function(date) {
      var dateLine = ['隔夜', '1周', '2周', '1个月', '3个月', '6个月', '9个月', '1年']
      return this.pick(dateLine)
    }
  });
  for (let i = 0; i < 8; i++) {
    let dateLine = Mock.Random.dateLine();
    let Shibor = Mock.Random.float(-10, 10, -2, 2);
    let BP = Mock.Random.float(0, 0, -2, 2);
    let data = {
      dateLine,
      Shibor,
      BP
    }
    resultArr.push(data);
  }
  return resultArr;
};
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_SHIBOR_DATA, () => {
  console.log(2)
  return {
    data: getShiborData()
  }
});

// 10.1 ---获取融资余额数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_FINANCE, (obj) => {
  let body = JSON.parse(obj.body) || ''
  let xTime;
  let length;
  switch (body.type) {
    case 0:
      length = 30;
      xTime = common.getDate('MM.dd', length)
      break;
    case 1:
      length = 91;
      xTime = common.getDate('yyyyMMdd', length)
      break;
    case 2:
      length = 365;
      xTime = common.getDate('yyyyMMdd', length)
      break;
  }
  return {
    xTime,
    shIndex: Array(length + 1).join(' ').split('').map(() => Math.round(Math.random() * 60) + 3100),
    finance: Array(length + 1).join(' ').split('').map(() => Math.round(Math.random() * 6000) + 8000),
    change: Array(length + 1).join(' ').split('').map(() => Math.round((Math.random() - 0.5) * 60))
  }
})

// 10.2 ---获取昨日融资融券余额明细
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_YST_FINANCE, () => {
  return Array.from({length: 10}, () => {
    return {
      strName: Random.cword(3, 4),
      strCode: Random.integer(610688, 620000),
      rzAmount: Random.integer(10000, 100000),
      rqAmount: Random.integer(10000000, 1000000000)
    }
  })
})

// 11.1 ---获取解禁市值数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_LIFTED, (obj) => {
  let body = JSON.parse(obj.body) || ''
  const getPreDate = (len) => {
    let res = ['今日'];
    let d = new Date();
    for (let i = 0; i < len - 1; i++) {
      d = new Date(d.getTime() + 1000 * 60 * 60 * 24)
      let a = `${common.fullZero(d.getMonth() + 1)}.${common.fullZero(d.getDate())}`
      res.push(a)
    }
    return res
  }
  let res;
  switch (body.type) {
    case 0:
      res = {
        xTime: common.getDate('MM.dd', 30),
        shIndex: Array(31).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 60) + 3100 }),
        amount: Array(31).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 60) + 80 })
      }
      break;
    case 1:
      res = {
        xTime: getPreDate(7),
        amount: Array(8).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 60) + 80 })
      }
      break;
    case 2:
      res = {
        xTime: getPreDate(30),
        amount: Array(31).join(' ').split('').map((item, index) => { return Math.round(Math.random() * 60) + 80 })
      }
      break;
  }
  return res
})

// 11.2 ---获取今日解禁个股明细
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_TODAY_LIFTED, () => {
  return {
    data: [
      {
        strName: '中国中车',
        strCode: 601688,
        amount: 8.5,
        persentage: 0.52,
        current: 1.0466
      },
      {
        strName: '中国中车',
        strCode: 601688,
        amount: 8.5,
        persentage: 0.52,
        current: 1.0466
      },
      {
        strName: '中国中车',
        strCode: 601688,
        amount: 8.5,
        persentage: 0.52,
        current: 1.0466
      },
      {
        strName: '中国中车',
        strCode: 601688,
        amount: 8.5,
        persentage: 0.52,
        current: 1.0466
      },
      {
        strName: '中国中车',
        strCode: 601688,
        amount: 8.5,
        persentage: 0.52,
        current: 1.0466
      }
    ]
  }
})

// 13.1 获取顶部的态势说明数据
Mock.mock(constant.baseURL + constant.InterfaceEnum.GET_TOP_DESC, (obj) => {
  let body = JSON.parse(obj.body) || '';
  let descList = [
    '当日净涨停3只，连续3日净涨停',
    '当日净涨停3只，连续3日净涨停',
    '连续3日净流入，累计流入65亿',
    '连续3日净流入，累计流入65亿',
    '连续3日净流入，累计流入65亿',
    '连续3日净流入，累计流入65亿',
    '连续3日净流入，累计流入65亿',
    '今日隔夜利率1.11%，比以前一交易日增加1.11%',
    '连续3日减少',
    '连续3日减少'
  ];
  return descList[body.type]
});
